package day8;

import java.util.Scanner;

import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID;

import day5.student;
import day9.Student;

public class StudentManger {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入学生数量");
		int count = sc.nextInt();
		Student[] array = new Student[count];
		for (int i = 0; i < array.length; i++) {
			System.out.println("请输入学生的年龄");
			int age = sc.nextInt();
			System.out.println("请输入学生姓名");
			String name = sc.next();
			System.out.println("请输入学生id");
			int id = sc.nextInt();

			Student student = new Student(age, name, id);
			array[i] = student;

		}
		while (true) {

			System.out.println("根据id查找输入：1");
			System.out.println("根据名字查找输入：2");
			System.out.println("根据年龄查找输入：3");

			System.out.println("退出程序：0");

			int type = sc.nextInt();
			if (type == 0) {
				System.out.println("退出程序");
				break;
			}

			switch (type) {
			case 1:
				System.out.println("根据id搜索");
				boolean isSearchByIdFound = false;
				int searchId = sc.nextInt();
				for (int i = 0; i < array.length; i++) {
					int id = array[i].getId();
					if (id == searchId) {
						isSearchByIdFound = true;
						System.out.println(array[i]);

					}
					if (isSearchByIdFound) {
						System.out.println("没有找到这个人");
					}

				}
				break;
			case 2://
				System.out.println("根据名字搜索");
				String searchName = sc.next();
				boolean isSearchByNameFound = false;
				for (int i = 0; i < array.length; i++) {

					searchName = sc.next();
					String name = array[i].getName();
					if (name.equals(searchName)) {
						System.out.println(array[i]);
						isSearchByNameFound = true;
						if (isSearchByNameFound) {
							System.out.println("没有找到这个人");

						}

					}
				}
				break;
			case 3:
				System.out.println("根据年龄查找");
				boolean isSearchByAge = false;
				for (int i = 0; i < array.length; i++) {
					int SearchAge = sc.nextInt();
					int age = array[i].getAge();
					if (age == SearchAge) {
						System.out.println(array[i]);
						isSearchByAge = true;
					}
					if (isSearchByAge) {
						System.out.println("没有找到这个人");
					}
					break;
				}
			default:
				break;
			}

		}
	}
}
